package com.sanjiahantang.youjiarole.module.programmeprice.modles.impl;

import android.content.Context;

import com.sanjiahantang.youjiarole.base.CallBack;
import com.sanjiahantang.youjiarole.config.ConfigValue;
import com.sanjiahantang.youjiarole.http.BaseDelegate;
import com.sanjiahantang.youjiarole.http.OkHttpClientManager;
import com.sanjiahantang.youjiarole.module.common.beans.StringBean;
import com.sanjiahantang.youjiarole.module.goods.beans.GoodsListBean;
import com.sanjiahantang.youjiarole.module.programmeprice.beans.ProgramAddOrderListBean;
import com.sanjiahantang.youjiarole.module.programmeprice.beans.ProgramBean;
import com.sanjiahantang.youjiarole.module.programmeprice.beans.ProgramOrderListBean;
import com.sanjiahantang.youjiarole.module.programmeprice.modles.IProgramPriceModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by admin on 2017/10/25.
 */

public class ProgramPriceModel implements IProgramPriceModel {


    @Override
    public void OnLoadBaoJList(final Context context, Map<String, Object> params, final CallBack<ProgramBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/project/price/phone/role/findProjectPlanInfo",params,new BaseDelegate.ResultCallback<ProgramBean>() {

            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(ProgramBean response, Object tag) {
                callBack.onSuccess(response,context, tag);
            }
        });

    }

    @Override
    public void SavePricePlanInfo(final Context context, Object params, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/project/price/phone/role/designerPush",params,new BaseDelegate.ResultCallback<StringBean>() {

            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(StringBean response, Object tag) {
                callBack.onSuccess(response,context, tag);
            }
        });
    }

    @Override
    public void findPlaceOrder(final Context context, Map<String, Object> params, final CallBack<ProgramBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/project/price/phone/role/findProjectPlanInfo",params,new BaseDelegate.ResultCallback<ProgramBean>() {

            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(ProgramBean response, Object tag) {
                callBack.onSuccess(response,context, tag);
            }
        });
    }
    //提交订单
    @Override
    public void creatOrderPhoneForPlan(final Context context, Object params, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderPhoneForPlan",params,new BaseDelegate.ResultCallback<StringBean>() {

            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(StringBean response, Object tag) {
                callBack.onSuccess(response,context, tag);
            }
        });
    }

    @Override
    public void resetGoodsList(final Context context, Map<String, Object> params, final CallBack<GoodsListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/mall/phone/goodsPage/searchMallGoodsInfoForPageForRole",
                params,new BaseDelegate.ResultCallback<GoodsListBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(GoodsListBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void findPlanInfo(final Context context, Map<String, String> param, final CallBack<ProgramOrderListBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/project/price/phone/role/findPlanInfo",param,new BaseDelegate.ResultCallback<ProgramOrderListBean>() {

            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(ProgramOrderListBean response, Object tag) {
                callBack.onSuccess(response,context, tag);
            }
        });
    }

    @Override
    public void addPriceOnLoadBaoJList(final Context context, Map<String, Object> params, final CallBack<ProgramAddOrderListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/findIncreaseList",params,new BaseDelegate.ResultCallback<ProgramAddOrderListBean>() {

            @Override
            public void onError(Request request, Object tag, Exception e) {
                callBack.onFailure(e.getMessage());
            }

            @Override
            public void onResponse(ProgramAddOrderListBean response, Object tag) {
                callBack.onSuccess(response,context, tag);
            }
        });
    }
}
